
import DininghallView from "../../dininghall/view/DininghallView";
import { EventName } from "../../../public/Config";
import GlobalEvent from "../../../cfw/event/GlobalEvent";
import LayerMgr from "../../../engine/LayerMgr";
import FoodItemModel from "../../dininghall/model/FoodItemModel";
import DragItemView from "../../item/DragItemView";

const { ccclass, property } = cc._decorator;

@ccclass
export default class BornStepView0 extends DininghallView {


    @property(cc.Node)
    angle: cc.Node = null;

    delegate(layerMgr: LayerMgr, index: number, item: cc.Node) {
        // cc.log(' delegate index ', index)
        let list: FoodItemModel[] = this.model.getList()
        let model = list[index]
        let comp = this.controller.initView(item, 'DragItemView', model) as DragItemView
        comp.updatePosition(this.posList[index].getPosition())
        // if (comp.isLoad()) {
        this.items[index] = comp;
        comp.init();
        comp.setIcon('texture/item/milk_bottle_2')
        // comp.refresh()

    }
    collideLogic() {
        if (!cc.isValid(this.node)) {
            return;
        }
        this.angle.active = false;
        cc.tween(this).to(2, {}).call(() => {
            GlobalEvent.instance().emit(EventName.UPDATE_SLEEP_STEP, 2)
        }).start();

    }


}
